"""
Author        yongfa
Date          2022-07-11 14:48:58
LastEditTime  2023-07-07 16:55:40
LastEditors   yongfa
Description   输出结构
"""


from flask_restx import fields, Model
from app.extensions.utils.schemas import CommonSchema, PageBaseSchema


UserBaseSchema = Model(
    "UserBaseSchema",
    {
        "id": fields.Integer(description="The user ID"),
        "username": fields.String(description="The user name"),
        "auth": fields.Integer(description="The user auth"),
        "address": fields.String(description="The user address"),
        "language": fields.String(description="The user language"),
        "extend": fields.String(description="The user extend"),
        "avatar": fields.String(description="The user avatar"),
        "active": fields.Boolean(description="The user active")

    }
)

# 用户详情
UserDetailSchema = CommonSchema.inherit("UserDetailSchema", {
    "result": fields.Nested(UserBaseSchema, description="The user data")
}
)

# 用户列表
UserListBaseSchema = PageBaseSchema.inherit("UserListBaseSchema", {
    "items": fields.List(fields.Nested(UserBaseSchema), description="The data list"),
}
)

# 分页列表
UserListSchema = CommonSchema.inherit('UserListSchema', {
    "result": fields.Nested(UserListBaseSchema, description="结果")
})


user_schemas = {
    "UserBaseSchema": UserBaseSchema,
    "UserDetailSchema": UserDetailSchema,
    "UserListBaseSchema": UserListBaseSchema,
    "UserListSchema": UserListSchema,
}
